﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ICSharpCode.SharpZipLib.Zip;
using COM.Web;
using ICSharpCode.SharpZipLib.GZip;
using WebApp.Service;

namespace WebApp.Web.Controllers
{
    public class FeedbackController : Controller
    {
        public ActionResult Index()
        {
            return this.RedirectToAction("List");
        }

        public ActionResult Create()
        {
            return View("Edit");
        }

        [HttpPost]
        public ActionResult Create(string userContent,string userInfo)
        {
            var userFeedback = Unity.Instance.GetService<IUserFeedbackService>();
            userFeedback.CreateUserFeedback("FromWebApp", DateTime.Now.ToString("yyyy-MM-dd"), Guid.Empty, userInfo, userContent);
            var s = new System.Web.Routing.RouteValueDictionary { { "from", "Create" } };
            return this.RedirectToAction("List",s);
        }

        public ActionResult Success()
        {
            return View();
        }

        public ActionResult List(string from)
        {
            ViewBag.From = from;
            var userFeedback = Unity.Instance.GetService<IUserFeedbackService>();
            ViewBag.UserFeedbackList = userFeedback.GetUserFeedbackList("FromWebApp");
            return View();
        }

        public ActionResult SendEmail()
        {
            var userFeedback = Unity.Instance.GetService<IUserFeedbackService>();
            ViewBag.UserFeedbackList = userFeedback.GetUserFeedbackList("SendEmail");
            return View("List");
        }
    }
}
